package cn.itsource.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.itsource.mapper.DriverMapper;
import cn.itsource.pojo.domain.Driver;
import cn.itsource.pojo.domain.DriverSummary;
import cn.itsource.mapper.DriverSummaryMapper;
import cn.itsource.pojo.vo.AppDriverSummaryVo;
import cn.itsource.service.IDriverService;
import cn.itsource.service.IDriverSummaryService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 司机结算对象 服务实现类
 * </p>
 *
 * @author whale
 * @since 2024-07-02
 */
@Service
public class DriverSummaryServiceImpl extends ServiceImpl<DriverSummaryMapper, DriverSummary> implements IDriverSummaryService {
    @Autowired
    private DriverMapper driverMapper;


    @Override
    public AppDriverSummaryVo getDriverSUmmary() {
        //获取openid
        String openid = StpUtil.getExtra("openid").toString();
        //根据id获取司机
        Driver one = driverMapper.selectOne(new LambdaQueryWrapper<Driver>().eq(Driver::getOpenId, openid));
        DriverSummary byId = super.getById(one.getId());
        AppDriverSummaryVo appDriverSummaryVo = new AppDriverSummaryVo();
        BeanUtil.copyProperties(byId,appDriverSummaryVo);
        return appDriverSummaryVo;
    }
}
